import type { MockMethod } from 'vite-plugin-mock'
// @ts-ignore
import Mock from "mockjs";

const list = Array(10).fill(0).map((_, i) => ({
  created_at: Mock.mock('@date(yyyy-MM-dd hh:mm:ss)'),
  updated_at: Mock.mock('@date(yyyy-MM-dd hh:mm:ss)'),
  deleted_at: Mock.mock('@date(yyyy-MM-dd hh:mm:ss)'),
  type: Mock.mock('@integer(0, 1)'),
  id: Mock.mock('@id'),
  userid: Mock.mock('@id'),
  name: Mock.mock('@cname'),
}))

export default [
  {
    url: '/mock/api/tag/create',
    method: 'post',
    response: ({ body }) => {
      return {
        code: 0,
        msg: '登录成功',
        data: {
          created_at: Mock.mock('@date(yyyy-MM-dd hh:mm:ss)'),
          updated_at: Mock.mock('@date(yyyy-MM-dd hh:mm:ss)'),
          deleted_at: Mock.mock('@date(yyyy-MM-dd hh:mm:ss)'),
          type: Mock.mock('@integer(0, 1)'),
          id: Mock.mock('@id'),
          userid: Mock.mock('@id'),
          name: Mock.mock('@cname'),
        }
      }
    }
  },
  {
    url: '/mock/api/tag/list',
    method: 'post',
    response: ({ body }) => {
      return {
        code: 0,
        msg: '登录成功',
        data: {
          page: 1,
          offset: 0,
          limit: 10,
          total: 100,
          list
        }
      }
    }
  }
] as MockMethod[]
